package com.hzlx;

import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class ConsumerController {
    @Resource
    RestTemplate restTemplate; //注入远程调用对象
    @GetMapping("/hello")
    public String producter(){                             //是目标服务的 注册名称（在目标服务的 application.yml 中定义
        String result=restTemplate.getForObject("http://producer-demo/producer",
                String.class);                //返回字符串
        return "hello:"+result;
    }
}
